﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlImage : JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlImage htmlImage;

        public JHtmlImage(System.Web.UI.HtmlControls.HtmlImage htmlImage)
            : base(htmlImage)
        {
            this.htmlImage = htmlImage;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "align":
                    Value = htmlImage.Align;
                    return;
                case "alt":
                    Value = htmlImage.Alt;
                    return;
                case "border":
                    Value = htmlImage.Border;
                    return;
                case "height":
                    Value = htmlImage.Height;
                    return;
                case "src":
                    Value = htmlImage.Src;
                    return;
                case "width":
                    Value = htmlImage.Width;
                    return;
                default:
                    base.Attr(key);
                    return;
            }
        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "align":
                    htmlImage.Align = value;
                    return;
                case "alt":
                    htmlImage.Alt = value;
                    return;
                case "border":
                    htmlImage.Border = b;
                    return;
                case "height":
                    htmlImage.Height = b;
                    return;
                case "src":
                    htmlImage.Src = value;
                    return;
                case "width":
                    htmlImage.Width = b;
                    return;
                default:
                    base.Attr(key, value);
                    return;
            }
        }

    }
}
